{% extends 'adm_base.html' %}

{% block title %}
    查看新闻详情
{% endblock %}

{% block content %}

    <section class="content">

        <div class="row">

            <div class="col-md-12">
                <!-- Message box -->
                <div class="box box-success">
                    <div class="box-header">
                        <i class="fa fa-newspaper-o"></i>

                        <h3 class="box-title">{{ news.title }}</h3>

                        <middle class="text-muted"><i
                                class="fa fa-clock-o"></i> {{ news.news_time }} </middle>

                        <div class="box-tools pull-right" data-toggle="tooltip" title="Status">
                            <div class="btn-group" data-toggle="btn-toggle">
                                <button type="button" class="btn btn-default btn-sm active"><i
                                        class="fa fa-square text-green"></i>
                                </button>
                                <button type="button" class="btn btn-default btn-sm"><i
                                        class="fa fa-square text-red"></i></button>
                            </div>
                        </div>
                    </div>

                    <div class="box-body fa-newspaper-o" id="news-box">
                        <p>
                            {{ news.content }}
                        </p>
                    </div>
                    <!-- /.chat -->
                    <div class="box-footer">
                        <button id="edit_btn" class="btn btn-success pull-left" type="button">
                            <span class="glyphicon glyphicon-pencil]">编辑新闻</span>
                        </button>
                        <a href="{% url 'tradingSystem:adm_delete_news' news.id %}"
                           class="btn btn-sm btn-danger btn-flat pull-right">删除新闻</a>
                    </div>
                </div>
                <!-- /.box (chat box) -->
            </div>

               <div class="modal fade" id="changeForm">
            <div class="modal-dialog">
                <div class="modal-content">
                    <form action="{% url 'tradingSystem:adm_edit_news' %}"  method="post">
                        {% csrf_token %}
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title">编辑新闻</h4>
                        </div>
                        <div class="modal-content" id="add_news_modal">
                            <div class="form-horizontal">

                                <div class="form-group">
                                    <label for="news_id" class="col-sm-2 control-label" style="color: red">新闻ID：</label>
                                    <div class="col-sm-10">
                                        <input type="text" id="news_id" class="form-control" readonly="readonly"
                                               name="news_id" value="{{ news.id }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="news_title" class="col-sm-2 control-label" style="color: red">新闻标题：</label>
                                    <div class="col-sm-10">
                                        <input type="text" id="news_title" class="form-control"
                                               name="news_title" value="{{ news.title }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="news_content" class="col-sm-2 control-label">新闻内容：</label>
                                    <div class="col-sm-10">
                                        <textarea name="news_content" id="news_content" class="form-control" rows="10">{{ news.content }}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <div class="center-block">
                                    <button id="cancelAdd" type="button" class="btn btn-default"
                                            data-dismiss="modal">取消
                                    </button>
                                    <button id="sureEdit" type="submit" class="btn btn-success">保存</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        </div>
        <div class="row">

        </div>

    </section>

{% endblock %}

{% block script %}
    <script>


        $(document).ready(function () {

           $('#edit_btn').click(function () {
               $('#changeForm').modal();
           });

        });
    </script>
{% endblock %}
